package com.hd.vote.User.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hd.vote.User.entity.Candidate;
import com.hd.vote.User.entity.Vote;
import com.hd.vote.User.service.ICandidateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hd
 * @since 2023-04-14
 */
@RestController
@RequestMapping("/User")
public class CandidateController {
    @Autowired
    ICandidateService candidateService;
    //第一题
    @GetMapping("/add")
    public HashMap<String,Object> add(Candidate candidate){
        HashMap<String,Object> map=new HashMap<>();
        boolean save = candidateService.save(candidate);
        if (save){
            map.put("msg","OK");
            map.put("code", 1);
        }else {
            map.put("msg","接口操作失败，请联系运维人员");
            map.put("code", -1);
        }
        return map;
    }
}
